<div class="artifact">
  <% if scope[:store_id_to_plugin_id].size == 0 %>
    <div class="information no_artifact_store">
      <div class="errors">
        No artifact store is configured<br/>
        Go to <%= link_to "artifact store page", '/go/admin/artifact_stores' -%> to configure artifact store.
      </div>
    </div>
  <% else %>
    <%= scope[:var_form].fields_for com.thoughtworks.go.config.JobConfig::ARTIFACT_CONFIGS, scope[:external_artifact], :index => "" do |artifact_form| %>
      <% external_artifact_config = scope[:external_artifact] %>
      <% uuid = random_dom_id %>
      <% plugged_artifact_angular_controller_element_id = random_dom_id("angular_" + uuid) %>
      <% plugged_artifact_data_element_id = random_dom_id("data_" + uuid) %>

      <div class="row expanded">
        <div class="columns medium-2 large-2"><h4 class="type">Type</h4>
          <span class="contextual_help has_go_tip_right" title="There are 3 types of artifacts - build, test and external. When 'Test Artifact' is selected, Go will use this artifact to generate a test report. Test information is placed in the Failures and Test sub-tabs. Test results from multiple jobs are aggregated on the stage detail pages. This allows you to see the results of tests from both functional and unit tests even if they are run in different jobs. When artifact type external is selected, you can configure the external artifact store to which you can push an artifact."/>
        </div>
        <div class="columns medium-3 large-3"><h4>ID</h4>
          <span class="contextual_help has_go_tip_right" title="This id is used to identify the artifact that is pushed to an external store. The id is used later in a downstream pipeline to fetch the artifact from the external store."/>
        </div>
        <div class="columns medium-3 large-3 end"><h4>Store ID</h4>
          <span class="contextual_help has_go_tip_right" title="This is a reference to the global artifact store defined in the config. At the time of publishing the artifact to an external store, the plugin makes use of the global properties associated with this store id."/>
        </div>
      </div>

      <div class="row expanded">
        <div class="name_value_cell columns medium-2 large-2">
          <label class="type_label">External Artifact</label>
          <%= artifact_form.hidden_field "artifactTypeValue", :class => "form_input artifact_source", :id => nil -%>
        </div>
        <div class="name_value_cell columns medium-3 large-3">
          <%= artifact_form.text_field "id", :class => "form_input artifact_source" -%>
          <%= error_message_on(scope[:external_artifact], "id", :css_class => "form_error") %>
        </div>
        <div class="name_value_cell columns medium-3 large-3">
          <%= artifact_form.text_field "storeId", :class => "form_input artifact_destination stores_auto_complete" -%>
          <%= error_message_on(scope[:external_artifact], "storeId", :css_class => "form_error") %>
        </div>
        <% if @is_config_repo_pipeline %>
          <div class="name_value_cell columns medium-4 large-4 end">
          </div>
        <% else %>
          <div class="name_value_cell columns medium-4 large-4 end">
            <span class="icon_remove delete_artifact" />
          </div>
        <% end %>
      </div>

      <div class="row expanded plugin_dropdown_background hidden">
        <div class="columns medium-8 medium-offset-2 large-8 end">
          <div class="plugin-select-form">
            <span>Cannot determine plugin to show the configuration view. Please choose a plugin to configure the plugin properties. <span class="contextual_help has_go_tip_right" title="The plugin with which the store is associated cannot be determined because: the store id is a parameter or store is non-existent."/></span>
            <label>Plugin</label>
            <%= select("", "pluginId", scope[:plugin_name_to_id], {:prompt => 'Select plugin', :selected => scope[:store_id_to_plugin_id][external_artifact_config.getStoreId]}, {:name => "job[artifactTypeConfigs][][pluginId]", :class => 'artifact_plugin_selection'}) %>
          </div>
        </div>
      </div>

      <div class="row expanded">
        <div class="columns medium-8 medium-offset-2 large-8 end">
          <div class="form_content">
            <%= render :partial => "admin/shared/global_errors.html", :locals => {:scope => {}} -%>
            <div id="material">
              <div class="fieldset">
                <div id="<%= plugged_artifact_angular_controller_element_id %>" name="<%= plugged_artifact_angular_controller_element_id %>" class="plugged_artifact">
                  <div class="form_item">
                    <div class="plugged_artifact_template">
                      <%== scope[:artifact_meta_data_store].publishTemplate(scope[:store_id_to_plugin_id][external_artifact_config.getStoreId()]) %>
                    </div>

                    <span id="<%= plugged_artifact_data_element_id %>" class="plugged_artifact_data" style="display: none">
                      <%= com.google.gson.Gson.new.toJson(external_artifact_config.getConfiguration().getConfigWithErrorsAsMap()) %>
                    </span>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <%= render :partial => 'shared/convert_tool_tips.html' %>
        </div>
      </div>
      <div class="row expanded plugin_key_value plugin_form_background">
        <div class="columns medium-8 medium-offset-2 large-8 end">
        </div>
      </div>
    <% end %>
  <% end %>
</div>
